/* 
 * Copyright (c)	Insighten Intelligent Equipment co.,LTD
 * 
 *  Use of this software is controlled by the terms and conditions found
 *  in the license agreement under which this software has been supplied.
 * 
 */
/** 
 * @file tcp_client.h
 * @brief library for tcp client
 * @author taco [tacoee@gmail.com]
 * @version 0.1
 * @date 2010-09-03
 */
#ifndef TCP_CLIENT_H_
#define TCP_CLIENT_H_

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <errno.h>

#include "rwbuf.h"
#include "sock_util.h"
#include "types.h"

struct _TcpClient;
typedef struct _TcpClient TcpClient;
struct _TcpClient {
	int fd;
	int port;
	struct sockaddr_in addr;
	socklen_t addr_len;
	char *host_name;
	struct hostent *svr_name;
	SocketAttr *attr;
	RwBuf	*buf;
	SockStat status;
};

TcpClient *tcp_client_new(void);
Ret tcp_client_destroy(TcpClient *thiz);
Ret tcp_client_init(TcpClient *thiz, int port, char *hsn, SocketAttr *attr, RwBuf *buf);
Ret tcp_client_create(TcpClient *thiz);
Ret tcp_client_connect(TcpClient *thiz);
int tcp_client_read(TcpClient *thiz, int size);
int tcp_client_wirte(TcpClient *thiz, int size);

#endif /*TCP_CLIENT_H_*/

